// pages/index/index.js
const request = require("../../utils/request1.js")
Page({
  data: {
    // 租赁详情
    Details:'',
    number: 0,
    Date:'',
    borders: [],
    position: [
      { value: 'bottom', text: '立即支付' },
    ],
    list:[
      {id:1,text:'首期月付',price:"￥155"},
      {id:2,text:'押金',price:"￥155"},
      {id:3,text:'共计',price:"￥155",color:'#b99946'},
      {id:4,text:'备注',price:"这是备注"}
    ],
    list1:[
      {id:1,text:'咖啡机咖啡机1',price:"待收货",color1:'#dac89d',
      color:'#0e0e0e',size:'1.1rem;',weight:'bold;'},
      {id:2,text:'价格',price:"￥200/月",color:'#cfcfcf'},
      {id:3,text:'押金',price:"￥200",color:'#cfcfcf'},
      {id:4,text:'规格',price:"22期",color:'#cfcfcf'},
      {id:5,text:'数量',price:"1",color:'#cfcfcf'},
    ],
    list2:[
      {id:1,text:'订单编号',text1:'154556565656'},
      {id:2,text:'物流编号',text1:'1662323'},
      {id:3,text:'订单状态',text1:'待支付'}
    ],
    list3:[
      {id:1,text:'价格',price:"￥200/月"},
      {id:2,text:'押金',price:"￥200"},
      {id:3,text:'共计',price:"15"}
    ],
  },
 
  onLoad: function () {
    this.createBorders();
    // 查询租赁详情接口
    this.getQueryOrdere ();
    //租赁期限接口
    this.getDate()
  },
      // 查询租赁详情接口
      getQueryOrdere (){
        const _this = this
        request.wxRequest('order/order?id=8', function (err, data) {
        // console.log(data.data.order);
        if (err) {
               // 失败；
        } else {
            _this.setData({
              Details:data.data.order
            })
        }
        }, 'GET', {
           id:8,
        })
    },
    //租赁期限接口
      getDate(){
        const _this = this
        request.wxRequest('order/spec?id=1', function (err, data) {
        // console.log(data.data.list);
        if (err) {
                 // 失败；
        } else {
            _this.setData({
              Date:data.data.list
          })
        }
      }, 'GET', {
          id:1,
      })
  },  
  // 返回上一页
  goInter(){
    wx.navigateBack({
      delta: 1
    })
},
  // 线
  createBorders: function () {
    const borders = [];
    for (let i = 1; i <= 18; i++) {
      const border = {};
      if (i % 2 === 0) {
        border.color = '#d4ddfc';
      } else {
        border.color = '#fbced1';
      }
      borders.push(border);
    }
    this.setData({ borders });
  },
  // 加减
  increaseNumber() {
    this.setData({
      number: this.data.number + 1,
    });
  },
  decreaseNumber() {
    if (this.data.number > 0) {
      this.setData({
        number: this.data.number - 1,
      });
    }
  },
    // popup
    handlePopup(e) {
      const { item } = e.currentTarget.dataset;
      this.setData(
        {
          cur: item,
        },
        () => {
          this.setData({ visible: true });
        },
      );
    },
    onVisibleChange(e) {
      this.setData({
        visible: e.detail.visible,
      });
    },
});
